<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <%@include file="/res/include/base-head.jsp"%>
	<%@include file="/res/include/jquery-easyui.jsp"%>
	<%@include file="/res/include/umeditor.jsp"%>
	<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/send/deliveryUser.js"></script>
  </head>
  <body>  
<div class="page_title clearfix">
    <h2>
    <c:if test="${!empty entity}">
    	编辑
    </c:if>
    <c:if test="${empty entity}">
    	新建
    </c:if>
    </h2>
</div>
<div class="form_item topic_add">
   <form id="data-form">
   	<c:if test="${!empty entity}">
    	<input type="hidden" name="id" value="${entity.id }"/>
    	<dl>
	        <dt>昵称：</dt>
	        <dd>${entity.userNick }</dd>
	    </dl>
    </c:if>
    <c:if test="${empty entity}">
    	<dl>
	        <dt>用户：</dt>
	        <dd>
	        	<input type="text" id="userNick" class="txt grid-25" readonly="readonly" onclick="admin.deliveryUser.chooseUser()"/>
	        	<input type="hidden" id="userId" name="userId" />
	        </dd>
	    </dl>
    </c:if>
    <dl>
        <dt>社区：</dt>
        <dd>
        <c:if test="${!empty entity}">
	    	<dd>${entity.communityName}</dd>
	    	<input type="hidden" id="communityId" name="communityId" value="${entity.communityId }"/>
	    </c:if>
	    <c:if test="${empty entity}">
	    	<dd>${community.name}</dd>
	    	<input type="hidden" id="communityId" name="communityId" value="${community.id}"/>
	    </c:if>
        </dd>
    </dl>
    <dl>
        <dt>上级用户：</dt>
        <dd>
        	<input type="text" id="parentName" class="txt grid-25" value="${entity.parentNick }" readonly="readonly" onclick="admin.deliveryUser.chooseParentId()"/>
        	<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true"
					onclick="clearParent();">去掉上级</a>
        	<input type="hidden" id="parentId" name="parentId" value="${entity.parentId }"/>
        	<input type="hidden" id="parentUserId" name="parentUserId" value="${entity.parentUserId }"/>
        </dd>
    </dl>
    </form>
    <p class="page_btn"><input type="button" id="doSave" value="保存" class="btn_blue" onclick="doSave();"/></p>
</div>
<script type="text/javascript">
function clearParent(){
	$('#parentName').val("");
	$('#parentId').val("");
	$('#parentUserId').val("");
}

var isSave = false;
//提交保存
function doSave(){
	
	var url = contextPath+'/send/deliveryUser/add';
	<c:if test="${!empty entity}">
		url = contextPath+'/send/deliveryUser/update';
	</c:if>
	if(!$('#data-form').form('validate')) return;
	if (isSave) {
		return;
	}
	isSave = true;
	var data = $('#data-form').form('jsonObject');
	//console.info("------------:"+JSON.stringify(data));
	$.post(url,data,function(result) {
		if(result.code==1) {
			top.showInfo('保存成功');
		} else {
			isSave = false;
			top.showInfo('保存失败:'+result.msg);
		}
	},'json');
}
</script>
  </body>
</html>
